const { defineConfig } = require('@vue/cli-service')
// const { resolve } = require('core-js/fn/promise')
module.exports = defineConfig({
  transpileDependencies: true,
  // rem配置
  css: {
    loaderOptions: {
      postcss: {
        postcssOptions: {
          plugins: [
            require('postcss-pxtorem')({
              rootValue: 75,
              propList: ['*']
            })
          ]
        }

      }
    }
  },
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/travel',
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:8080', // 写后台接口地址
        // ws: true,
        changeOrigin: true,
        logLevel: 'debug',
        pathRewrite: {
          '/api': '/mock'
        }
      }
    }
  },
  configureWebpack: (config) => {
    const plugins = []
    config.devtool = 'eval-source-map'
    if (process.env.NODE_ENV !== 'production') {
      // 开发环境配置
      config.devtool = 'eval-source-map'
    } else {
      // 生产环境配置
      // 添加gzip压缩

      config.optimization.minimizer[0].options.minimizer.options.compress.drop_console = true
      config.optimization.minimizer[0].options.minimizer.options.compress.drop_debugger = true
    }

    config.plugins = [...config.plugins, ...plugins]
  }
})
